package com.siyao.redvip.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPreferencesUtils {

	private static final String PREFERENCENAME = "PREFERENCE_REDVIP360";

	public static void saveAccount(Context context, String account) {
		SharedPreferences sp = context.getSharedPreferences(PREFERENCENAME,
				Context.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putString("account", account);
		editor.commit();
	}

	public static void savePasswd(Context context, String pwd) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		Editor editor = mSharedPreferences.edit();
		editor.putString("pwd", pwd);
		editor.commit();
	}

	public static void setSavePasswd(Context context, boolean b) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		Editor editor = mSharedPreferences.edit();
		editor.putBoolean("isSavePasswd", b);
		editor.commit();
	}

	public static boolean isSavePasswd(Context context) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		return mSharedPreferences.getBoolean("isSavePasswd", true);
	}

	public static String getAccount(Context context) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		return mSharedPreferences.getString("account", "");
	}

	public static String getPasswd(Context context) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		return mSharedPreferences.getString("pwd", "");
	}

	public static boolean getIsFrist(Context context) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		return mSharedPreferences.getBoolean("isFrist", true);
	}

	public static void setFrist(Context context,boolean b) {
		SharedPreferences mSharedPreferences = context.getSharedPreferences(
				PREFERENCENAME, Context.MODE_PRIVATE);
		Editor editor = mSharedPreferences.edit();
		editor.putBoolean("isFrist", b);
		editor.commit();
	}
}
